import Vue from "vue";
import App from "./App";
import router from "./router";
import axios from "axios";
Vue.prototype.$axios = axios;

Vue.config.productionTip = false;
import store from "./store";

import glComponents from "./components/glComponents";
Vue.use(glComponents);



//时间转化
import moment from "moment";
Vue.prototype.$moment = moment;

// 引入复制粘贴
import VueClipboard from "vue-clipboard2";
Vue.use(VueClipboard)

// 引入md5
import md5 from 'js-md5';
Vue.prototype.$md5 = md5;

import CMD from "./utils/cmd";
Vue.prototype.CMD = CMD;


import {
  NoticeBar,
  swipe,
  SwipeItem,
  Switch,
  Toast,
  Rate,
  Icon,
  List,
  Picker,
  Popup,
  Dialog,
  Checkbox,
  CheckboxGroup,
  CountDown,
  Step,
  Steps,
  RadioGroup,
  Radio,
  NumberKeyboard,
  PullRefresh,
  Lazyload,
  SwipeCell,
  Button,
  PasswordInput,
  Field,
  Cell,
  CellGroup,
  DatetimePicker,
  Tab,
  Tabs,
  Uploader,
  Collapse,
  CollapseItem,
  NavBar,
  ImagePreview,
  Sticky,
  Circle,
  Search,
  ActionSheet
} from "vant";
Vue.use(ActionSheet);
Vue.use(Popup);
Vue.use(Picker);
Vue.use(List);
Vue.use(Step);
Vue.use(Steps);
Vue.use(Switch)
  .use(Icon)
  .use(Circle)
  .use(Search)
  .use(Checkbox)
  .use(CheckboxGroup)
  .use(CountDown)
  .use(Radio)
  .use(RadioGroup)
  .use(NumberKeyboard)
  .use(PullRefresh)
  .use(SwipeCell)
  .use(Button)
  .use(PasswordInput)
  .use(Field )
  .use(Cell )
  .use(CellGroup )
  .use(Dialog)
  .use(DatetimePicker)
  .use(Tab)
  .use(Tabs)
  .use(Uploader)
  .use(Collapse)
  .use(CollapseItem)
  .use(NoticeBar)
  .use(swipe)
  .use(SwipeItem)
  .use(Sticky)
  .use(Rate)
  .use(NavBar)
  .use(Lazyload, {
    preLoad: 1.3,
    error: "../static/images/error.png",
    loading: "../static/images/error.png",
    attempt: 1
  });
  import '@vant/touch-emulator';
Vue.prototype.Dialog = Dialog;
Vue.prototype.Toast = Toast;
Vue.prototype.ImagePreview = ImagePreview;
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
// import vueSwiper from "vue-awesome-swiper";
// import "swiper/dist/css/swiper.css";
// Vue.use(vueSwiper);

// 引入qrcode
// import VueQriously from "vue-qriously";
// Vue.use(VueQriously);

import pinyin from 'js-pinyin'
Vue.prototype.$pinyin = pinyin;
// 引入API列表
import URL from "./utils/url";
Vue.prototype.URL = URL;


// 公共js
import common from "./utils/common.js";
Vue.prototype.common = common;

import "../static/css/reset.css";
import "../static/js/rem.js";
import "../static/iconfont/iconfont.css";

import { post, get } from "./utils/http";
//定义全局变量
Vue.prototype.$post = post;
Vue.prototype.$get = get;

import locales from './assets/languages/vantLocal'
//将次方法暴露给Vue原型上
Vue.prototype.$Local = locales;
//设置默认语言


if(localStorage.getItem("language") == null){
  localStorage.setItem("language",'zh')
}
import lottie from 'vue-lottie';
Vue.component('lottie', lottie)


import VueI18n from "vue-i18n";
Vue.use(VueI18n);
const i18n = new VueI18n({
  locale: localStorage.getItem("language") || "zh", //使用localStorage缓存到本地
  messages: {
    zh: require("./assets/languages/zh.json"),  //中简
    en: require("./assets/languages/en.json"),  //英
    jp: require("./assets/languages/jp.json"), //日本
    hi_IN: require("./assets/languages/hi_IN.json"), //印地
    in_ID: require("./assets/languages/in_ID.json"),
    vi_VN: require("./assets/languages/vi_VN.json"),
    ko_KR: require("./assets/languages/ko_KR.json"),
    th_TH: require("./assets/languages/th_TH.json")  //泰
  }
});

router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});

// post请求是格式化数据
import qs from "qs";
Vue.prototype.$qs = qs;

/* eslint-disable no-new */
new Vue({
  el: "#app",
  i18n,
  router,
  store,
  components: { App },
  template: "<App/>"
});
